/**
 * 
 */
package t4j.holding;

import java.util.LinkedList;

class Stack<T> {
	
	private LinkedList<T> storage = new LinkedList<T>();
	
	public void push(T t){ storage.addFirst(t);}
	
	public T peek(){return storage.getFirst();}
	
	public T pop(){ return storage.removeFirst();}
	
	public boolean empty(){return storage.isEmpty();}

	public String toString(){return storage.toString();}
}

public class StackTest {

	public static void main(String[] args) {
		Stack<String> stack = new Stack<String>();
		
		for(String s : "My dog has fleas".split(" "))
			stack.push(s);
		
		while( !stack.empty())
			System.out.println(stack.pop());
		
		java.util.Stack<String> stack2 = new java.util.Stack<String>();
		
		for(String s : "My dog has fleas".split(" "))
			stack2.push(s);
		while( !stack2.empty())
			System.out.println(stack2.pop());
		
	}
}
